package com.xy.mvvmdemo.fragment

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.PagerAdapter

/**
 * @ClassName FragmentAdapter
 * @Author xy
 * @Date 2021/7/8 14:41
 * @Description
 */
@Suppress("DEPRECATION")
class MyFragmentAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {

    var fragmentList = mutableListOf<Fragment>()

    constructor(fm: FragmentManager,fragmentList:MutableList<Fragment>):this(fm){
        this.fragmentList = fragmentList
    }

    override fun getCount(): Int {
       return fragmentList.size
    }

    override fun getItem(position: Int): Fragment {
        return fragmentList[position]
    }

    override fun getItemPosition(`object`: Any): Int {
        return PagerAdapter.POSITION_NONE
    }
}